const name = '成绩'
const modules = {}

// const files = require.context('./consumption-modules', false, /\.js$/)
// files.keys().forEach(key => {
//   modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
// })

export default {
  namespaced: true,
  modules: modules,
  state: {
    __prefix: '',
    __name: name,

    score: 0,
    detailList: []
  },

  getters: {},

  mutations: {
    updateScore(state, score) {
      state.score = score
    },
    updateDetailList(state, list) {
      state.detailList = list
    }
  },

  actions: {
    __autoload({ dispatch, state }, prefix) {
      state.__prefix = prefix + '/'
      console.log(`[store][${state.__prefix}${state.__name}] 初始化`)

      Object.keys(modules).forEach(key => {
        if (!!modules[key]['actions'] && !!modules[key]['actions']['__autoload']) {
          dispatch(`${key}/__autoload`, state.__prefix + state.__name)
        }
      })
    }
  }
}
